package com.bawei.caohao0802.view.activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.bawei.caohao0802.MyApp
import com.bawei.caohao0802.R
import com.bawei.caohao0802.databinding.ActivityMainBinding
import com.bawei.caohao0802.viewmodel.MainVewiModel
import com.bawei.caohao20240730.base.BaseActivity

//代码及布局文件符合编码规范，有核心代码及布局属性有相关注释
class MainActivity : BaseActivity<MainVewiModel,ActivityMainBinding>(R.layout.activity_main) {
    override fun dataObser() {
        mViewModel.dengdata.observe(this, Observer {
            if(it.status=="0000"){
                MyApp.sessionId=it.result.sessionId
                MyApp.userId="${it.result.userId}"

                Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show()
                startActivity(Intent(this,LeiActivity::class.java))
            }
        })
    }

    override fun initView() {
        mDing.deng.setOnClickListener {
            mViewModel.getdeng(mDing.phone.text.toString(),mDing.pwd.text.toString())

        }
    }

}